import * as Beautifier from "js-beautify";
const beautifierConf = {
    html: {
        indent_size: "4",
        indent_char: " ",
        max_preserve_newlines: "-1",
        preserve_newlines: false,
        keep_array_indentation: false,
        break_chained_methods: false,
        indent_scripts: "separate",
        brace_style: "end-expand",
        space_before_conditional: true,
        unescape_strings: false,
        jslint_happy: false,
        end_with_newline: true,
        wrap_line_length: "110",
        indent_inner_html: true,
        comma_first: false,
        e4x: true,
        indent_empty_lines: true,
    },
    js: {
        indent_size: "4",
        indent_char: " ",
        max_preserve_newlines: "-1",
        preserve_newlines: false,
        keep_array_indentation: false,
        break_chained_methods: false,
        indent_scripts: "normal",
        brace_style: "end-expand",
        space_before_conditional: true,
        unescape_strings: false,
        jslint_happy: true,
        end_with_newline: true,
        wrap_line_length: "110",
        indent_inner_html: true,
        comma_first: false,
        e4x: true,
        indent_empty_lines: true,
    },
};

/**
 * 格式化文本
 * @param {*} str
 * @returns
 */
export function beautifyVue(str) {
    if (!str) return "";
    return Beautifier.html(str, beautifierConf);
}

export function beautifyJS(jsStr) {
    if (!jsStr) return "";
    return Beautifier.js(jsStr, beautifierConf.js);
}
